package com.lvandroid.play.player;

import androidx.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * 对外统一的播放器管理类
 */
public class AllRoundPlayerManager {

    private static AllRoundPlayerManager sINSTANCE;

    private AllRoundPlayerManager() {}

    public static AllRoundPlayerManager getInstance() {
        if(null == sINSTANCE) {
            synchronized (AllRoundPlayerManager.class) {
                if(null == sINSTANCE) {
                    sINSTANCE = new AllRoundPlayerManager();
                }
            }
        }

        return sINSTANCE;
    }

    public static AllRoundPlayer createPlayer(@PlayerType int player) {
        AllRoundPlayer iPlayer = getInstance().getPlayerInternal(player);
        return iPlayer;
    }

    private AllRoundPlayer getPlayerInternal(int player) {
        switch (player) {
            case MEDIA_TYPE_VIDEO:
                return new VideoPlayer();

            case MEDIA_TYPE_AUDIO:
                return new AudioPlayer();

            case MEDIA_TYPE_IMAGE:
                return new ImagePlayer();
            case MEDIA_TYPE_HTML:
                return new HTMLPlayer();

            case MEDIA_TYPE_FLASH:

                break;

            case MEDIA_TYPE_PDF:
                return new PDFPlayer();

            case MEDIA_TYPE_PPT:

                break;

            case MEDIA_TYPE_WORD:
                return new DocPlayer();
            case MEDIA_TYPE_EXCEL:

                break;

            case MEDIA_TYPE_RTMP:

                break;

            case MEDIA_TYPE_OFFICE:

                break;

            case MEDIA_TYPE_SCRIPT:

                break;

            case MEDIA_TYPE_STREAM:

                break;

            case MEDIA_TYPE_ALBUM:

                break;

            case MEDIA_TYPE_DANMU:

                break;

            case MEDIA_TYPE_DATE:

                break;

            case MEDIA_TYPE_TEXT:
                return new TextPlayer();
            default:
                break;
        }

        return null;
    }

    public static final int MEDIA_TYPE_BASE = 0;
    //视频
    public static final int MEDIA_TYPE_VIDEO = MEDIA_TYPE_BASE + 1;
    //音频
    public static final int MEDIA_TYPE_AUDIO = MEDIA_TYPE_BASE + 2;
    //图片
    public static final int MEDIA_TYPE_IMAGE = MEDIA_TYPE_BASE + 3;
    //HTML
    public static final int MEDIA_TYPE_HTML = MEDIA_TYPE_BASE + 4;
    //FLASH
    public static final int MEDIA_TYPE_FLASH = MEDIA_TYPE_BASE + 5;
    //PDF
    public static final int MEDIA_TYPE_PDF = MEDIA_TYPE_BASE + 6;
    //PPT
    public static final int MEDIA_TYPE_PPT = MEDIA_TYPE_BASE + 7;
    //WORD
    public static final int MEDIA_TYPE_WORD = MEDIA_TYPE_BASE + 8;
    //EXCEL
    public static final int MEDIA_TYPE_EXCEL = MEDIA_TYPE_BASE + 9;
    //RTMP视频流
    public static final int MEDIA_TYPE_RTMP = MEDIA_TYPE_BASE + 10;
    //OFFICE
    public static final int MEDIA_TYPE_OFFICE = MEDIA_TYPE_BASE + 11;
    //Script
    public static final int MEDIA_TYPE_SCRIPT = MEDIA_TYPE_BASE + 12;
    //Stream
    public static final int MEDIA_TYPE_STREAM = MEDIA_TYPE_BASE + 13;
    //相册
    public static final int MEDIA_TYPE_ALBUM = MEDIA_TYPE_BASE + 14;
    //弹幕文字
    public static final int MEDIA_TYPE_DANMU = MEDIA_TYPE_BASE + 15;
    //日期
    public static final int MEDIA_TYPE_DATE = MEDIA_TYPE_BASE + 16;
    //文字
    public static final int MEDIA_TYPE_TEXT = MEDIA_TYPE_BASE + 17;

    @IntDef({
            MEDIA_TYPE_VIDEO,
            MEDIA_TYPE_AUDIO,
            MEDIA_TYPE_IMAGE,
            MEDIA_TYPE_HTML,
            MEDIA_TYPE_FLASH,
            MEDIA_TYPE_PDF,
            MEDIA_TYPE_PPT,
            MEDIA_TYPE_WORD,
            MEDIA_TYPE_EXCEL,
            MEDIA_TYPE_RTMP,
            MEDIA_TYPE_OFFICE,
            MEDIA_TYPE_SCRIPT,
            MEDIA_TYPE_STREAM,
            MEDIA_TYPE_ALBUM,
            MEDIA_TYPE_DANMU,
            MEDIA_TYPE_DATE,
            MEDIA_TYPE_TEXT
    })

    @Retention(RetentionPolicy.SOURCE)
    public @interface PlayerType {}
}
